<html>

<head>

<?php

include "../includes/constants.php";

?>

<title>View Petitions</title>

</head>

<body>

<center><h1>Petitions</h1></center>

<table align="center" border="1">
	<tr>
		<th title="dib"></th>
		<th title="petid">ID</th>
		<th title="charname">Char</th>
		<th title="accountname">Acct</th>
		<th title="lastgm"></th>
		<th title="petitiontext">Petition</th>
		<th title="gmtext"></th>
		<th title="zone">Zone</th>
		<th title="urgency"></th>
		<th title="charclass">Class</th>
		<th title="charrace">Race</th>
		<th title="charlevel">Lvl</th>
		<th title="checkouts"></th>
		<th title="unavailables"></th>
		<th title="ischeckedout"></th>
		<th title="senttime">Created</th>
	</tr>
<?php

if (!isset($_GET["sort"])) {
	$_GET["sort"] = "petid";
};
$query = "SELECT * FROM petitions ORDER BY " . $_GET["sort"] . " ASC ";
$result = mysql_query($query,$db);

if ($db_row = mysql_fetch_array($result)) {
	do {
		echo "\t<tr>
		<td>" . $db_row["dib"] . "</td>
		<td>" . $db_row["petid"] . "</td>
		<td>" . $db_row["charname"] . "</td>
		<td>" . $db_row["accountname"] . "</td>
		<td>" . $db_row["lastgm"] . "</td>
		<td>" . $db_row["petitiontext"] . "</td>
		<td>" . $db_row["gmtext"] . "</td>
		<td>" . $db_row["zone"] . "</td>
		<td>" . $db_row["urgency"] . "</td>
		<td>" . $Classes[$db_row["charclass"]] . "</td>
		<td>" . $db_row["charrace"] . "</td>
		<td>" . $db_row["charlevel"] . "</td>
		<td>" . $db_row["checkouts"] . "</td>
		<td>" . $db_row["unavailables"] . "</td>
		<td>" . $db_row["ischeckedout"] . "</td>
		<td>" . date("Y-m-d H:i:s",$db_row["senttime"]) . "</td>\n";
	} while ($db_row = mysql_fetch_array($result));
} else {
	echo "\t<tr>
		<td colspan=\"16\">No results found</td>
	</tr>\n";
};

?>
</table>

</body>

</html>